home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
- Begin VB.Form frmTrayIcon
- BorderStyle = 3 'Fixed Dialog
- Caption = "SG Window - TrayIcon Sample"
- ClientHeight = 3285
- ClientLeft = 2640
- ClientTop = 2805
- ClientWidth = 4980
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3285
- ScaleWidth = 4980
- ShowInTaskbar = 0 'False
- Begin VB.PictureBox pctIcon
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- BorderStyle = 0 'None
- Height = 435
- Left = 240
- ScaleHeight = 435
- ScaleWidth = 495
- TabIndex = 3
- Top = 780
- Width = 495
- End
- Begin VB.CommandButton cmdSetIcon
- Caption = "Change Icon"
- Height = 435
- Left = 3420
- TabIndex = 2
- Top = 840
- Width = 1395
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 4320
- Top = 1500
- _ExtentX = 847
- _ExtentY = 847
- _Version = 327681
- End
- Begin VB.CommandButton cmdTip
- Caption = "Change Tooltip"
- Height = 435
- Left = 3420
- TabIndex = 1
- Top = 240
- Width = 1395
- End
- Begin VB.TextBox txtTooltip
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 238
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 240
- TabIndex = 0
- Text = "Text1"
- Top = 240
- Width = 3075
- End
- Begin VB.Label lblStatus
- Height = 315
- Left = 120
- TabIndex = 4
- Top = 2880
- Width = 4695
- End
- Begin VB.Menu mnuPopup
- Caption = "Popup"
- Visible = 0 'False
- Begin VB.Menu mnuShow
- Caption = "Show Form"
- End
- Begin VB.Menu mnuHide
- Caption = "Hide Form"
- End
- Begin VB.Menu mnuExit
- Caption = "E&xit"
- End
- End
- Attribute VB_Name = "frmTrayIcon"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '--------------------------------------------------------------------------
- ' This file is part of the SG Window
- ' This sample shows how to use SG Window to put form into the
- ' system try. Note that all code needed to add and manage
- ' tray icon API is encapsulated in the TrayIcon class.
- ' Copyright
- 1998 Stinga
- ' All rights reserved
- ' You have a right to use and modify this code. However,
- ' Stinga is not responsible for what you may do with this
- ' or any modification of this code.
- '--------------------------------------------------------------------------
- Option Explicit
- ' Declare TrayIcon object and connect to it's events
- Private WithEvents mTray As SGTrayIcon.TrayIcon
- Attribute mTray.VB_VarHelpID = -1
- Private Sub cmdSetIcon_Click()
- CommonDialog1.Filter = "Icon Files (*.ico)|*.ico||"
- CommonDialog1.ShowOpen
- If CommonDialog1.filename <> "" Then
- Set pctIcon.Picture = LoadPicture(CommonDialog1.filename)
- Set mTray.Icon = pctIcon.Picture
- End If
- End Sub
- Private Sub cmdTip_Click()
- mTray.Tip = txtTooltip.Text
- txtTooltip.Text = mTray.Tip
- End Sub
- Private Sub Command1_Click()
- Set mTray.Icon = Me.Icon
- End Sub
- Private Sub Form_Load()
- ' Create TrayIcon object and connect to tray icon events
- Set mTray = New SGTrayIcon.TrayIcon
- ' Initialize tray icon object
- ' Set owner form and menu that will be used as a
- ' popup menu when user clicks with right mouse button
- Set mTray.Form = Me
- Set mTray.PopupMenu = mnuPopup
- ' Set tray icon and tooltip text
- Set mTray.Icon = Me.Icon
- mTray.Tip = "SG Window TrayIcon Sample"
- ' Add icon to the system tray
- mTray.Add
- ' Update form controls
- txtTooltip.Text = mTray.Tip
- Set pctIcon.Picture = mTray.Icon
- End Sub
- Private Sub Form_Terminate()
- ' Remove icon from the system tray
- mTray.Remove
- End Sub
- Private Sub mnuExit_Click()
- Unload Me
- End Sub
- Private Sub mnuHide_Click()
- Me.Hide
- End Sub
- Private Sub mnuShow_Click()
- Me.Show
- End Sub
- Private Sub mTray_DblClick(ByVal x As Single, ByVal y As Single)
- If Me.Visible Then
- Me.Hide
- Else
- Me.Show
- End If
- End Sub
- Private Sub mTray_MouseMove(ByVal x As Single, ByVal y As Single)
- lblStatus.Caption = "MouseMove at " & CStr(x) & ", " & CStr(y)
- End Sub
-